#include "DemuxTable.h"

void DemuxTable::convert_to_fd_sets(fd_set *read_fds, fd_set *write_fds, fd_set *except_fds)
{
	FD_ZERO(read_fds);
	FD_ZERO(write_fds);
	FD_ZERO(except_fds);

	for(int i = 0; i < HANDLE_CONNECTION_SIZE; i++)
	{
		if(handleConnection[i].eventType == READ_EVENT)
		{
			FD_SET(handleConnection[i].eventhandler->get_handle().getConnection(), read_fds);
		}
		
		else if(handleConnection[i].eventType == WRITE_EVENT)
		{
			FD_SET(handleConnection[i].eventhandler->get_handle().getConnection(), write_fds);
		}

		else if(handleConnection[i].eventType == ACCEPT_EVENT)
		{
			FD_SET(handleConnection[i].eventhandler->get_handle().getConnection(), read_fds);
		}

		else if(handleConnection[i].eventType == INIT_EVENT)
		{
			FD_SET(handleConnection[i].eventhandler->get_handle().getConnection(), write_fds);
		}
	}
}